package cn.org.donald.framework.service.impl;

import cn.org.donald.framework.pojo.dto.RequestInfo;
import cn.org.donald.framework.service.ServletRequestService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author : Donald
 * @since : 2020/12/16 13:54
 */
@Service(version = "1.0.0", group = "donald")
public class ServletRequestServiceImpl implements ServletRequestService {

    @Autowired
    private RequestInfo requestInfo;

    /**
     * 注入HttpServletRequest相关参数
     *
     * @param requestInfo
     * @return
     */
    @Override
    public boolean setRequestBody(RequestInfo requestInfo) {
        try {
            this.requestInfo.setUserId(requestInfo.getUserId());
            this.requestInfo.setAuthorization(requestInfo.getAuthorization());
            this.requestInfo.setIp(requestInfo.getIp());
            return true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }
}
